﻿using UnityEngine;

public class SpikePlatformCtl : PlatformCtl
{

    readonly Vector2 leftPos = new Vector2 { x = -0.25f, y = 0.255f };
    readonly Vector2 rightPos = new Vector2 { x = 0.27f, y = 0.255f };


    Transform spikeTransform;

    public override void Start()
    {
        base.Start();

        spikeTransform = transform.GetChild(0);
        spikeTransform.localPosition = SpikeRandomPosition;

    }


    public override void Update()
    {
        base.Update();
    }

    Vector2 SpikeRandomPosition
    {
        get => (Random.Range(0f, 2f) > 1f) ? leftPos : rightPos;
    }


    public void OnTouchSpike(float spikeX)
    {
        GameManager.Instance.PlayerGameObject.GetComponent<PlayerController>().HurtState(spikeX);
    }

}
